# -*- coding: utf-8 -*-
#
# File: SIGFS.py
#
# Copyright (c) 2006 by IBICT
# Generator: ArchGenXML Version 1.5.0
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

__author__ = """IBICT <cadu@ibict.br>"""
__docformat__ = 'plaintext'


from Products.CMFCore.utils import getToolByName
from Products.ExternalMethod.ExternalMethod import ExternalMethod

##code-section module-header #fill in your manual code here
##/code-section module-header

def installWorkflows(self, package, out):
    """Install the custom workflows for this product."""

    productname = 'SIGFS'
    workflowTool = getToolByName(self, 'portal_workflow')

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_escritorio_workflow',
                                        'createsigfs_escritorio_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_escritorio_workflow')
    if 'sigfs_escritorio_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_escritorio_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_escritorio_workflow', workflow)
    workflowTool.setChainForPortalTypes(['EscritorioVirtualComite', 'EscritorioVirtualSecretaria'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_reuniao_workflow',
                                        'createsigfs_reuniao_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_reuniao_workflow')
    if 'sigfs_reuniao_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_reuniao_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_reuniao_workflow', workflow)
    workflowTool.setChainForPortalTypes(['Reuniao'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_ata_workflow',
                                        'createsigfs_ata_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_ata_workflow')
    if 'sigfs_ata_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_ata_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_ata_workflow', workflow)
    workflowTool.setChainForPortalTypes(['Ata'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_resolucao_workflow',
                                        'createsigfs_resolucao_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_resolucao_workflow')
    if 'sigfs_resolucao_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_resolucao_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_resolucao_workflow', workflow)
    workflowTool.setChainForPortalTypes(['Resolucao', 'Resolucao'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_atividade_workflow',
                                        'createsigfs_atividade_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_atividade_workflow')
    if 'sigfs_atividade_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_atividade_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_atividade_workflow', workflow)
    workflowTool.setChainForPortalTypes(['Atividade'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_termo_referencia_workflow',
                                        'createsigfs_termo_referencia_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_termo_referencia_workflow')
    if 'sigfs_termo_referencia_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_termo_referencia_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_termo_referencia_workflow', workflow)
    workflowTool.setChainForPortalTypes(['TermoReferencia', 'DocumentoTecnico'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_chamada_publica_workflow',
                                        'createsigfs_chamada_publica_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_chamada_publica_workflow')
    if 'sigfs_chamada_publica_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_chamada_publica_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_chamada_publica_workflow', workflow)
    workflowTool.setChainForPortalTypes(['ChamadaPublica'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_carta_convite_workflow',
                                        'createsigfs_carta_convite_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_carta_convite_workflow')
    if 'sigfs_carta_convite_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_carta_convite_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_carta_convite_workflow', workflow)
    workflowTool.setChainForPortalTypes(['CartaConvite', 'Encomenda'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_ata_reservada_workflow',
                                        'createsigfs_ata_reservada_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_ata_reservada_workflow')
    if 'sigfs_ata_reservada_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_ata_reservada_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_ata_reservada_workflow', workflow)
    workflowTool.setChainForPortalTypes(['AtaReservada'], workflow.getId())

    ourProductWorkflow = ExternalMethod('temp', 'temp',
                                        productname+'.'+'sigfs_proposta_workflow',
                                        'createsigfs_proposta_workflow')
    workflow = ourProductWorkflow(self, 'sigfs_proposta_workflow')
    if 'sigfs_proposta_workflow' in workflowTool.listWorkflows():
        print >> out, 'sigfs_proposta_workflow already in workflows.'
    else:
        workflowTool._setObject('sigfs_proposta_workflow', workflow)
    workflowTool.setChainForPortalTypes(['Proposta'], workflow.getId())

    ##code-section after-workflow-install #fill in your manual code here
    ##/code-section after-workflow-install

    return workflowTool

def uninstallWorkflows(self, package, out):
    """Deinstall the workflows.

    This code doesn't really do anything, but you can place custom
    code here in the protected section.
    """

    ##code-section workflow-uninstall #fill in your manual code here
    ##/code-section workflow-uninstall

    pass
